<!DOCTYPE html>
<html>
<head>
  <title></title>
  <meta charset="UTF-8">
  <script type="text/javascript">
  var exampleSocket = new WebSocket("ws://192.168.187.131:9502?party=12&user=1");

  // 打开 web socket
  exampleSocket.onopen = function (event) {
    exampleSocket.send("亲爱的服务器！我连上你啦！");
  };

  // 监听消息
  exampleSocket.onmessage = function (event) {
    console.log(event.data);
  }

  function sendMessage(message)
  {
      var data = {
        'party': 12,
        'message':message
      }
      exampleSocket.send(data)
  }
  </script>
</head>
<body>
<input  type="text" id="content">
<button  onclick="sendMessage( document.getElementById('content').value )">发送</button>
</body>
</html>
